from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from tortoise.contrib.fastapi import register_tortoise

from app.api.test import test
from app.api.wwk import wwk
from settings import TORTOISE_ORM
import uvicorn
from app.routers.users import users

app = FastAPI()
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 只使用Tortoise-ORM注册
register_tortoise(
    app,
    config=TORTOISE_ORM,
    generate_schemas=True,
    add_exception_handlers=True,
)


app.include_router(users, prefix='/api', tags=['用户管理'])
app.include_router(test,prefix='/api/test',tags=['测试接口'])
# app.include_router(api,prefix='/api/api',tags=['api'])
app.include_router(wwk,prefix='/api/wwk',tags=['wwk接口'])



if __name__ == '__main__':
    uvicorn.run("main:app", host='127.0.0.1', port=8000, reload=True)
